const db = require('../models');
const User = db.User;

const findUserByWxacount = async (wxUserAccount) => {
    try {
        const results = await User.findAll({
            where: {
                wxUserAccount: wxUserAccount
            }
        });
        if((results.length > 0)) {
            return true;
        } else {
            return false;
        }
    } catch (error) {
        return false;
    }
}

const findUserInfo = async (query) => {
    try {
        const results = await User.findAll({
            where: {
                tableNum: query.tableNum,
                barID: query.barID,
                state: 1
            }
        });
        return results;
    } catch (error) {
        console.log("Error: " + error);
        return error;      
    }
}


module.exports = {findUserByWxacount,findUserInfo};